$OpenBSD: patch-bin_check_mailscanner,v 1.2 2011/04/21 20:25:35 sthen Exp $
--- bin/check_mailscanner.orig	Wed Mar 16 19:41:34 2011
+++ bin/check_mailscanner	Thu Apr 21 18:41:07 2011
@@ -42,8 +42,8 @@
 # unless MailScanner actually had to be started.
 
 process=MailScanner
-msbindir=/opt/MailScanner/bin
-config=/opt/MailScanner/etc/MailScanner.conf
+msbindir=%PREFIX%/bin
+config=%SYSCONFDIR%/MailScanner/MailScanner.conf
 
 # These seem to get put all over the shop...
 PATH=/usr/bin:/bin
@@ -121,7 +121,9 @@ if [ "x$pid" = "x" ]; then
   PATH=${msbindir}:$PATH
   echo -n 'Starting MailScanner...'
   cd $msbindir
-  $process $config 2>/dev/null || RETVALUE=" Failed."
+  username=$(awk '/^Run As User/ {print $5;}' /etc/MailScanner/MailScanner.conf)
+  [ -n "$username" -a "$(whoami)" != "$username" ] && preamble="su -l -s /bin/sh $username -c "
+  $preamble $process $config 2>/dev/null || RETVALUE=" Failed."
   echo "$RETVALUE"
 else
   if [ "x$1" != "x-q" ]; then
